home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CUJ9209.ARJ / 1009047A < prev    next >
Text File  |  1992-04-03  |  1KB  |  54 lines

  1. /***                 LISTING 4                ***/
  2. /***                                          ***/
  3. /***                  intin.c                 ***/
  4. /*** **************************************** ***/
  5. /***    INTERRUPT TO HANDLE DATA RECEIVED     ***/
  6. /*** **************************************** ***/
  7. #include "serial.h"
  8.  
  9. extern  int portbase;
  10.  
  11. static  char  buf[SBUFSIZ];
  12. static  int  bufptr   = 0;
  13. static  int  byteptr  = 0;
  14.  
  15. extern  void  (interrupt far *oldvect)();
  16.  
  17. void interrupt far ReceiveData(void)
  18. {
  19.  
  20.   if((inp(portbase + IIR) & RX_MASK) == RX_ID)
  21.     {
  22.      buf[bufptr++] = inp(portbase + RXR);
  23.  
  24.      if(bufptr >= SBUFSIZ)
  25.     bufptr = 0;
  26.     }
  27.  
  28. /***     Signal end of hardware interrupt     ***/
  29.  
  30.   outp(ICR,EOI);
  31.  
  32.   (*oldvect)();
  33. }
  34.  
  35. /*** **************************************** ***/
  36. /***         GRABS A BYTE FROM BUFFER         ***/
  37. /*** **************************************** ***/
  38. int  IntSerialIn(void)
  39. {
  40.   int Char_Value;
  41.  
  42.   if (byteptr == bufptr)
  43.     {
  44.      return (-1);
  45.     }
  46.  
  47.   Char_Value = (int)buf[byteptr++];
  48.  
  49.   if(byteptr >= SBUFSIZ)
  50.      byteptr = 0;
  51.  
  52.   return (Char_Value);
  53. }
  54.